1. Field of the Invention
The present invention generally relates to computer graphics and more particularly to a method and system for configuring a graphics processing unit (GPU).
2. Description of the Related Art
Over the past decade, graphics hardware has gone from a simple memory device to a configurable device and relatively recently, to a GPU. In a prior art approach, a GPU includes a series of processing units, each is configured to carry out a different and often dedicated function of a graphics pipeline, where the output of one processing unit is the input to the next processing unit in the chain. Some of these processing units in the graphics pipeline are programmable, such as a vertex processing unit and a fragment processing unit, but other processing units perform fixed functions, such as a primitive assembler, a geometry processor, and a rasterizer.
When using programmable processing units, applications provide a collection of shaders, which are programs executed on these units. The device driver managing such hardware typically must not only compile and enable such shaders, but must also configure other pipeline units based on properties of the active shaders. In one example, a device driver must configure depth testing to be performed after pixel shader execution when using a pixel shader that writes a depth value. In another example, a device driver for hardware capable of executing multiple shaders concurrently may need to partition a fixed-size memory available for temporary storage during shader execution based on the memory requirements of multiple active shaders.
In prior art systems, device drivers processing a new shader will typically send a sequence of commands to the graphics hardware. This sequence will not only specify and enable the shader code, but it will also configure other units of the graphics hardware whose operation depends on properties of the shader. This sequence of commands will be sent not only when the shader is first used, but also repeatedly when switching among a collection of different shaders—a typical behavior for graphics applications. This repeated re-configuration consumes significant processing and memory resources and introduces undesirable delays. Additionally, as noted above, some hardware state needs to be configured based on the properties of multiple shaders. For this sort of state, re-configuration is required when any shader is changed, and the processing and memory resource overhead is even more pronounced because it requires analyzing the state of multiple shaders at once.
As the foregoing illustrates, what is needed in the art is a more efficient method and system for configuring a graphics pipeline for execution.